home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / elm / elm2.4 / lib / errno.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-20  |  3.3 KB  |  110 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: errno.c,v 5.3 1993/04/21 01:58:20 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 5.3 $   $State: Exp $
  6.  *
  7.  *            Copyright (c) 1988-1992 USENET Community Trust
  8.  *            Copyright (c) 1986,1987 Dave Taylor
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log: errno.c,v $
  17.  * Revision 5.3  1993/04/21  01:58:20  syd
  18.  * change to detect strerror routine
  19.  * From: Syd
  20.  *
  21.  * Revision 5.2  1993/04/21  01:25:11  syd
  22.  * Use strerror() with ANSI compilers.
  23.  * From: decwrl!uunet.UU.NET!fin!chip (Chip Salzenberg)
  24.  *
  25.  * Revision 5.1  1992/10/03  22:41:36  syd
  26.  * Initial checkin as of 2.4 Release at PL0
  27.  *
  28.  *
  29.  ******************************************************************************/
  30.  
  31. /** This routine maps error numbers to error names and error messages.
  32.     These are all directly ripped out of the include file errno.h, and
  33.     are HOPEFULLY standardized across the different breeds of Unix!!
  34.  
  35.     If (alas) yours are different, you should be able to use awk to
  36.     mangle your errno.h file quite simply...
  37.  
  38. **/
  39.  
  40. #include "headers.h"
  41.  
  42. #ifndef STRERROR
  43. #ifdef ERRLST
  44. extern char *sys_errlist[];
  45. extern int sys_nerr;
  46. #else
  47. static char *sys_errlist[] = { 
  48. /*  0 - NOERROR    */ "No error status currently",
  49. /*  1 - EPERM    */ "Not super-user",
  50. /*  2 - ENOENT    */ "No such file or directory",
  51. /*  3 - ESRCH    */ "No such process",
  52. /*  4 - EINTR    */ "Interrupted system call",
  53. /*  5 - EIO    */ "I/O error",
  54. /*  6 - ENXIO    */ "No such device or address",
  55. /*  7 - E2BIG    */ "Arg list too long",
  56. /*  8 - ENOEXEC    */ "Exec format error",
  57. /*  9 - EBADF    */ "Bad file number",
  58. /* 10 - ECHILD    */ "No children",
  59. /* 11 - EAGAIN    */ "No more processes",
  60. /* 12 - ENOMEM    */ "Not enough core",
  61. /* 13 - EACCES    */ "Permission denied",
  62. /* 14 - EFAULT    */ "Bad address",
  63. /* 15 - ENOTBLK    */ "Block device required",
  64. /* 16 - EBUSY    */ "Mount device busy",
  65. /* 17 - EEXIST    */ "File exists",
  66. /* 18 - EXDEV    */ "Cross-device link",
  67. /* 19 - ENODEV    */ "No such device",
  68. /* 20 - ENOTDIR    */ "Not a directory",
  69. /* 21 - EISDIR    */ "Is a directory",
  70. /* 22 - EINVAL    */ "Invalid argument",
  71. /* 23 - ENFILE    */ "File table overflow",
  72. /* 24 - EMFILE    */ "Too many open files",
  73. /* 25 - ENOTTY    */ "Not a typewriter",
  74. /* 26 - ETXTBSY    */ "Text file busy",
  75. /* 27 - EFBIG    */ "File too large",
  76. /* 28 - ENOSPC    */ "No space left on device",
  77. /* 29 - ESPIPE    */ "Illegal seek",
  78. /* 30 - EROFS    */ "Read only file system",
  79. /* 31 - EMLINK    */ "Too many links",
  80. /* 32 - EPIPE    */ "Broken pipe",
  81. /* 33 - EDOM    */ "Math arg out of domain of func",
  82. /* 34 - ERANGE    */ "Math result not representable",
  83. /* 35 - ENOMSG    */ "No message of desired type",
  84. /* 36 - EIDRM    */ "Identifier removed"
  85.     };
  86. static int sys_nerr = 37;
  87. #endif /* ERRLST */
  88. #endif /* STRERROR */
  89.  
  90. char *error_description(errnumber)
  91. int errnumber;
  92. {
  93. #ifdef STRERROR
  94.  
  95.     return strerror(errnumber);
  96.  
  97. #else /* !STRERROR */
  98.  
  99.     static char buffer[50];
  100.  
  101.     if (errnumber < 0 || errnumber >= sys_nerr)  {
  102.       sprintf(buffer,"ERR-UNKNOWN (%d)", errnumber);
  103.       return(buffer);
  104.     }
  105.  
  106.     return( sys_errlist[errnumber] );
  107.  
  108. #endif /* !STRERROR */
  109. }
  110.